﻿using TaskManager.Domain.BusinessObjects;

namespace TaskManager.Domain.Services
{
    /// <summary>
    /// Service that handles task modification
    /// </summary>
    internal class TaskUpdateService : ITaskUpdateService
    {
        /// <summary>
        /// Updates task's attributes and logs important changes
        /// </summary>
        /// <param name="task">Task</param>
        /// <param name="summary">New summary value</param>
        /// <param name="description">New description value</param>
        /// <param name="priority">New priority value</param>
        /// <param name="assignee">New assignee value</param>
        /// <param name="owner">New owner value</param>
        public void Update(Task task, string summary, string description, int priority, string assignee, string owner)
        {
            task.Summary = summary;
            task.Description = description;
            task.Priority = priority;

            if (task.Assignee != assignee)
            {
                task.ReassignTo(assignee);
            }

            if(task.Owner != owner)
            {
                task.ChangeOwner(owner);
            }
        }
    }
}